package service;

import bean.User;
import dao.LoginTranferDao;
import protectjava.jdbc.DataSourceUtils;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Map;

public class LoginTransferService {


    public boolean isOk(User user) {
//        调用dao层处理
        LoginTranferDao login = new LoginTranferDao();
        Connection conn = null;
        boolean result = false;
        try {
//            获得连接
            conn = DataSourceUtils.getConnection();
//            开启事物
            conn.setAutoCommit(false);
//            调用查询方法
            result= login.password(user,conn);
    } catch (Exception e) {
            e.printStackTrace();
//            关闭事物
            try {
                conn.rollback();
            } catch (SQLException ex) {
                ex.printStackTrace();
            }

        } finally {
//            提交事物
            try {
                conn.commit();
            } catch (SQLException e) {
                e.printStackTrace();
            }

        }

        return  result;
    }
}
